home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Especial Multimedia
/
Especial Multimedia.iso
/
Multimed
/
Prg
/
BMP2PIC.ZIP
/
BMP2PIC.BAS
< prev
next >
Wrap
BASIC Source File
|
1997-09-14
|
2KB
|
50 lines
Option Explicit
' Written by: Ron Edwards
' PRISM Corp. Please don't hesitate to point out bugs or make
' Hiroshima, Japan other suggestions/comments. Samples of your unique
' CIS: 71125,534 solutions to programming challenges are appreciated.
' Windows API Declarations/Definitions
' Function's
Declare Function BitBlt% Lib "GDI" (ByVal hDestDC%, ByVal X%, ByVal Y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal YSrc%, ByVal dwRop&)
Declare Function CreateCompatibleBitmap% Lib "GDI" (ByVal hDC%, ByVal nWidth%, ByVal nHeight%)
Declare Function CreateCompatibleDC% Lib "GDI" (ByVal hDC%)
Declare Function DeleteDC% Lib "GDI" (ByVal hDC%)
Declare Function DeleteObject% Lib "GDI" (ByVal hObject%)
Declare Function GetBitmapBits& Lib "GDI" (ByVal hBitmap%, ByVal dwCount&, ByVal lpBits As Any)
Declare Function GlobalLock& Lib "Kernel" (ByVal hMem%)
Declare Function GlobalSize& Lib "Kernel" (ByVal hMem%)
Declare Function GlobalUnlock% Lib "Kernel" (ByVal hMem%)
Declare Function SelectObject% Lib "GDI" (ByVal hDC%, ByVal hObject%)
' Constants
Const SRCCOPY = &HCC0020
' User defined globals
Global rc%, i%
Global ctlSOURCE As Control, ctlDEST As Control, ctlREALKEY As Control
Sub CopyBmp2Pic (keyleft%, keytop%)
Dim compatDC%, compatbmp%, bmpsize&, memptr&
compatDC% = CreateCompatibleDC(ctlDEST.hDC) ' Must use control that has hDC
compatbmp% = CreateCompatibleBitmap(compatDC%, 17, 17)
rc% = SelectObject(compatDC%, ctlDEST.Picture) ' Must already contain the same kind/size bmp
rc% = BitBlt(compatDC%, 0, 0, 17, 17, ctlSOURCE.hDC, keyleft% + 2, keytop% + 2, SRCCOPY)
bmpsize& = GlobalSize(compatbmp%)
memptr& = GlobalLock(ctlDEST.Picture)
rc% = GetBitmapBits(compatbmp%, bmpsize&, memptr& + bmpsize&)
rc% = GlobalUnlock(ctlDEST.Picture)
ctlREALKEY.PictureUp = ctlDEST.Picture ' Copy to the key
rc% = DeleteDC(compatDC%)
rc% = DeleteObject(compatbmp%)
End Sub